//
//  BCPhonePopView.m
//  BangcaiDriver
//
//  Created by apple on 16/9/23.
//  Copyright © 2016年 BC. All rights reserved.
//

#import "BCPhonePopView.h"

@interface BCPhonePopView  ()
{
    UIImageView *userImgView;
    UILabel *nameLab;
    UILabel *addressLab;
    UIButton *phoneBut;
    
}

@property(nonatomic, strong)UIView *coverView;
@property(nonatomic, strong)UIView *alertView;

@end

@implementation BCPhonePopView

- (instancetype)initWithImg:(UIImage *)userImg name:(NSString *)name add:(NSString *)address phone:(NSNumber *)phoneNum
{
    _userImg = userImg;
    _name = name;
    _address = address;
    _phoneNum = phoneNum;
    self = [super init];
    if (self) {
      
    }
    return self;
}

- (void)createView{
    self.coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.coverView.backgroundColor = [UIColor blackColor];
    self.coverView.alpha = .7;
    [self addSubview:self.coverView];
    self.alertView = [[UIView alloc] init];
    [self addSubview:self.alertView];
    self.alertView.layer.cornerRadius = 3;
    self.alertView.layer.borderColor = BangcaiOrange.CGColor;
    self.alertView.layer.borderWidth = 1;
    self.alertView.layer.masksToBounds = YES;
    self.alertView.backgroundColor = [UIColor whiteColor];
    [self createAlertView];
    [self.alertView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(330 *wx);
        make.height.mas_equalTo(150 *wx);
        make.centerX.mas_equalTo(SCREEN_WIDTH/2);
        make.centerY.mas_equalTo(SCREEN_HEIGHT/2 -36);
        
    }];
}

- (void)createAlertView
{
    userImgView = [[UIImageView alloc] initWithImage:self.userImg];
    userImgView.layer.cornerRadius = 35*wx;
    userImgView.layer.masksToBounds = YES;
    nameLab = [[UILabel alloc] init];
    nameLab.text = self.name;
    nameLab.font = [UIFont systemFontOfSize:17];
    
    addressLab = [[UILabel alloc] init];
    addressLab.font = [UIFont systemFontOfSize:16];
    addressLab.textColor = [UIColor colorWithRed:0.510 green:0.510 blue:0.510 alpha:1];
    addressLab.text = self.address;
    phoneBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [phoneBut setImage:[UIImage imageNamed:@"拨打电话"] forState:UIControlStateNormal];
    
    
    [self.alertView addSubview:nameLab];
    [self.alertView addSubview:addressLab];
    [self.alertView addSubview:phoneBut];
    [self addSubview:userImgView];

    
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(userImgView.mas_bottom).with.offset(12);
        make.centerX.mas_equalTo(0);
    }];
    
    [addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(nameLab.mas_bottom).with.offset(12);
        make.centerX.mas_equalTo(0);
        
    }];
    
    [phoneBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(addressLab.mas_bottom).with.offset(12);
        make.centerX.mas_equalTo(0);
        
    }];
    [userImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.and.width.mas_equalTo(70 * wx);
        make.centerX.mas_equalTo(SCREEN_WIDTH/2);
        make.centerY.mas_equalTo(self.alertView.mas_top);
        
    }];

}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
